package com.juku2024.juku.adapter

import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.TextView
import androidx.recyclerview.widget.RecyclerView
import com.juku2024.juku.R
import com.juku2024.juku.model.DebLockingMoreEntity

/**
 * Created by fq on 2017/6/7.
 */
class DebLockingAdapter(private val areas: List<DebLockingMoreEntity>) :
    RecyclerView.Adapter<DebLockingAdapter.DebLockingViewHolder>() {

    override fun onCreateViewHolder(p0: ViewGroup, viewType: Int): DebLockingViewHolder {
        return DebLockingViewHolder(
            LayoutInflater.from(p0.context).inflate(R.layout.item_deblocking, p0, false)
        )
    }

    override fun onBindViewHolder(holder: DebLockingViewHolder, p1: Int) {
        val item = areas[p1]
        holder.tvArea.text = item.name

        holder.itemView.setOnClickListener {
            onItemClickListener?.onItemClick(p1)
        }
    }

    override fun getItemCount(): Int {
        return areas.size
    }

    class DebLockingViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView) {
        var tvArea: TextView = itemView.findViewById(R.id.tvArea)
    }


    interface OnItemClickListener {
        fun onItemClick(pos: Int)
    }

    var onItemClickListener: OnItemClickListener? = null


}